'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var operationModel = baseController.getBaseDocFields();
//工艺路线
operationModel.Routing = {
    type: Schema.ObjectId,
    ref: 'Routing'
};
//序号
operationModel.Sequence = {
    type: Number
};
//工序名称
operationModel.Name = {
    type: String,
    default:'',
    trim: true
};
//标准作业
operationModel.Work = {
    type: Schema.ObjectId,
    ref: 'Work'
};
//准备工时
operationModel.ReadyWorkHours = {
    type: Number
};
//加工工时
operationModel.MachinWorkHours = {
    type: Number
};
//上线控制
operationModel.IsOnlineControl = {
    type: Boolean,
    default: false
};
//下线控制
operationModel.IsOfflineControl = {
    type: Boolean,
    default: false
};
//交接区
operationModel.ConnectArea = {
    type: Schema.ObjectId,
    ref: 'ConnectArea'
};
//是否完工入库点
operationModel.IsCompletePoint = {
    type: Boolean,
    default: false
};
//是否质检点
operationModel.IsQCpoint = {
    type: Boolean,
    default: false
};
//允许扫描次数
operationModel.ScanCounts = {
    type: Number
};
operationModel.IsEffective = {
    type: Boolean
};

var operationSchema = new Schema(operationModel);
operationSchema.index({Routing: 1, Sequence: 1}, {"unique": true});

mongoose.model('Operation', operationSchema, 'Operation');
